import {
  createRouter,
  createWebHashHistory,
  createWebHistory,
} from "vue-router";
export const constantRoutes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/index",
    name: "首页",
    component: () => import("@/views/Index.vue"),
  },
  {
    path: "/newDetail/:uuid/:author",
    name: "NewDetail",
    props: true ,
    component: () => import("@/views/newDetail/index.vue"),
  },
  {
    path: "/latestNews",
    name: "最新消息",
    component: () => import("@/views/latestNews.vue"),
  },
  {
    path: "/watchlist",
    name: "关注列表",
    component: () => import("@/views/watchList/index.vue"),
  },
  {
    path: "/markets",
    name: "市场",
    component: () => import("@/views/market/index.vue"),
  },
  {
    path: "/stockDetail/:symbol",
    name: "stockDetail",
    component: () => import("@/views/stockDetail/index.vue"),
  },
  {
    path: "/market/:nation",
    name: "市场下子菜单",
    component: () => import("@/views/nationMarket/index.vue"),
  },
  {
    path: "/marketsData",
    name: "市场数据中心",
    component: () => import("@/views/marketsData/index.vue"),
  },
  {
    path: "/inverting",
    name: "投资",
    component: () => import("@/views/inverting/index.vue"),
  },
  {
    path: "/inverting/:data",
    name: "投资子菜单",
    component: () => import("@/views/compreInverting/index.vue"),
  },
  {
    path: "/personalFinance",
    name: "个人财务",
    component: () => import("@/views/personalFinance.vue"),
  },
  {
    path: "/personalFinance/:nation",
    name: "个人财务子菜单",
    component: () => import("@/views/personalFinance/regionFull.vue"),
  },
  {
    path: "/economyPage",
    name: "经济",
    component: () => import("@/views/economyPage.vue"),
  },

  {
    path: "/login",
    name: "登录",
    component: () => import("@/views/user/login.vue"),
  },
  {
    path: "/singin",
    name: "注册",
    component: () => import("@/views/user/singin.vue"),
  },
  {
    path: "/retireMent",
    name: "退休",
    component: () => import("@/views/retireMent/index.vue"),
  },
  {
    path: "/videoCenter",
    name: "视频中心",
    component: () => import("@/views/videoCenter.vue"),
  },
  {
    path: "/videoDetail",
    name: "视频详情",
    component: () => import("@/views/video/videoDetails/videoDetail.vue"),
  },
  {
    path: "/marketPickets",
    name: "市场观察精选",
    meta: {
      pickHeader: true,
    },
    component: () => import("@/views/marketPickets/index.vue"),
  },
  {
    path: "/marketPickets/:nation",
    name: "市场观察精选子菜单",
    meta: {
      pickHeader: true,
    },
    component: () => import("@/views/marketPickets/money/money.vue"),
  },
  {
    path: "/author/:id",
    name: "authordetails",

    component: () => import("@/views/author/author.vue"),
  }
];
const router = createRouter({
  history: createWebHistory(),
  //history: createWebHashHistory(),
  routes: constantRoutes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      return { top: 0 };
    }
  },
});

export default router;
